<template>
	<!-- 简历编辑 -->
	<div class="p-resume-edit">
		<!-- 个人信息 -->
		<v-info :resource="resource"></v-info>
		<!-- 操作按钮 -->
		<!-- <div class="p-resume-edit-btn flexItems">
			<button class="zmlBtn1">保存</button>
			<button class="zmlBtn3" @click="$router.back()">取消</button>
		</div> -->
		
		<!-- 编辑内容 -->
		<div class="p-edit-content">
			<!--头像-->
			<div class="company-userinfo-head flex">
				<div class="company-userinfo-head-img flexCenter">
					<img :src="imgUrl + resource.headPicture" alt="" v-if="resource.headPicture != ''" />
					<span v-else>{{$t('common.resume.avatar')}}</span>
				</div>
				<div class="company-userinfo-head-text flexColumn">
					<p class="h99">{{ $t('common.company.companytask4') }}</p>
					<p class="h99">{{ $t('common.company.companytask5') }}</p>
					<el-upload action="" :before-upload="photoUpload">
						<span class="color1">{{ $t('common.company.upload') }}</span>
					</el-upload>
				</div>
			</div>

			<!-- 基本信息 -->
			<div class="p-edit-box">
				<div class="zmlTitle">{{$t('common.detail.EssentialInfo')}}</div>
				<div class="p-edit-infor">
					<div class="p-edit-row flex-lect">
						<div class="p-edit-cos">
							<label class="p-edit-title">{{$t('common.detail.salaryRequire')}}：</label>
							<el-select v-model="resource.salaryRange" :placeholder="$t('common.newJob.select')" :popper-append-to-body="false">
								<el-option v-for="item in options_price" :key="item.value" :label="item.text" :value="item.value"></el-option>
							</el-select>
						</div>
						<div class="p-edit-cos" style="margin-left:30px">
							<label>{{$t('common.detail.birthday')}}：</label>
							<el-date-picker
								id="establishmentDate"
								class="cur"
								v-model="resource.birthDate"
								type="date"
								:placeholder="this.$t('common.form.select', [$t('common.detail.birthday')])">
							</el-date-picker>
						</div>
						<div class="p-edit-cos"></div>
					</div>
					<div class="p-edit-row flexBetween">
						<div class="p-edit-cos">
							<label class="p-edit-title">{{$t('common.company.name')}}：</label>
							<el-input v-model="resource.userName" placeholder="" maxlength="20"></el-input>
						</div>
						<div class="p-edit-cos">
							<label class="p-edit-title">{{$t('common.company.sex')}}：</label>
							<el-select v-model="resource.sex" :placeholder="$t('common.newJob.select')" :popper-append-to-body="false">
								<el-option v-for="item in options_sex" :key="item.value" :label="item.text" :value="item.value"></el-option>
							</el-select>
						</div>
						<div class="p-edit-cos">
							<label class="p-edit-title">{{$t('common.detail.natureIdentity')}}：</label>
							<el-select v-model="resource.identityProperties" :placeholder="$t('common.newJob.select')" :popper-append-to-body="false">
								<el-option v-for="item in options_nature" :key="item.value" :label="item.text" :value="item.value"></el-option>
							</el-select>
						</div>
					</div>
					<div class="p-edit-row flexBetween">
						<div class="p-edit-cos">
							<label class="p-edit-title">{{$t('common.detail.house')}}：</label>
							<el-cascader v-model="domicileNationality" :options="options_house" :props="{ expandTrigger: 'hover', value: 'value' }" @change="handleChangeHouse" separator="-" :placeholder="$t('common.newJob.select')"></el-cascader>
						</div>
						<div class="p-edit-cos">
							<label class="p-edit-title">{{$t('common.detail.IDNumber')}}：</label>
							<el-input v-model="resource.idNumber" @input="getidNumber" placeholder="" maxlength="18"></el-input>
						</div>
						<div class="p-edit-cos">
							<label class="p-edit-title">{{$t('common.detail.maritalStatus')}}：</label>
							<el-select v-model="resource.married" :placeholder="$t('common.newJob.select')" :popper-append-to-body="false">
								<el-option v-for="item in options_marry" :key="item.value" :label="item.text" :value="item.value"></el-option>
							</el-select>
						</div>
					</div>
					<div class="p-edit-row flexBetween">
						<div class="p-edit-cos">
							<label class="p-edit-title">{{$t('common.company.phone')}}：</label>
							<el-input v-model="resource.phone" placeholder="" @input="getPhone" maxlength="11"></el-input>
						</div>
						<div class="p-edit-cos">
							<label class="p-edit-title">{{$t('common.detail.Email')}}：</label>
							<el-input v-model="resource.email" placeholder="" maxlength="20"></el-input>
						</div>
						<div class="p-edit-cos">
							<label class="p-edit-title">{{$t('common.detail.address')}}：</label>
							<el-cascader v-model="address" :options="options_address" :props="{ expandTrigger: 'hover', value: 'value'  }" @change="handleChangeAddress" separator="-" :placeholder="$t('common.newJob.select')"></el-cascader>
						</div>
					</div>
				</div>
			</div>

			<!-- 教育信息 -->
			<div class="p-edit-box">
				<div class="p-edit-head flexBetween">
					<div class="zmlTitle">{{$t('common.detail.educationalInfo')}}</div>
					<span class="zmlAdd color1" @click="addEducation">
						<i class="el-icon-circle-plus-outline"></i>
						{{$t('common.detail.add')}}
					</span>
				</div>
				<div v-for="(obj, idx) in eduInfos" :key="idx" class="p-edit-zml p-edit-education">
				<!-- <div class="p-edit-zml p-edit-education"> -->
					<div class="p-edit-row flexBetween">
						<div class="p-edit-cos">
							<label class="p-edit-title">{{$t('common.resume.time')}}：</label>
							<el-date-picker :editable="false" @input="rangeDateInput(idx, 'edu')" value-format="yyyy-MM" v-model="obj.date" type="monthrange" range-separator="~" :start-placeholder="$t('common.resume.start')" :end-placeholder="$t('common.resume.end')"></el-date-picker>
						</div>
					</div>
					<div class="p-edit-row flexBetween">
						<div class="p-edit-cos">
							<label class="p-edit-title">{{$t('common.resume.school')}}：</label>
							<el-input v-model="obj.schoolName" placeholder="" maxlength="20"></el-input>
						</div>
						<div class="p-edit-cos">
							<label class="p-edit-title">{{$t('common.resume.edu')}}：</label>
							<el-select v-model="obj.education" :placeholder="$t('common.newJob.select')" :popper-append-to-body="false">
								<el-option v-for="item in education_educa_options" :key="item.value" :label="item.text" :value="item.value"></el-option>
							</el-select>
						</div>
						<div class="p-edit-cos">
							<label class="p-edit-title">{{$t('common.resume.professional')}}：</label>
							<el-input v-model="obj.professional" placeholder="" maxlength="20"></el-input>
						</div>
					</div>
					<div class="p-edit-row">
						<div class="p-edit-cos flex">
							<label class="p-edit-title">{{$t('common.resume.schoolDesc')}}：</label>
							<el-input type="textarea" :rows="5" placeholder="" v-model="obj.description" resize="none" maxlength="500"></el-input>
						</div>
					</div>
					<div class="p-edit-row-btns">
						<!-- <button class="zmlBtn2">保存</button> -->
						<span class="h66" @click="educaDelete(idx)">{{$t('common.operate.delete')}}</span>
					</div>
				</div>
			</div>

			<!-- 荣誉及证书 -->
			<div class="p-edit-box">
				<div class="p-edit-head flexBetween">
					<div class="zmlTitle">{{$t('common.resume.honorCert')}}</div>
					<span class="zmlAdd color1" @click="addHonor">
						<i class="el-icon-circle-plus-outline"></i>
						{{$t('common.detail.add')}}
					</span>
				</div>
				<div class="p-edit-honor">
					<table>
						<tr>
							<td>{{$t('common.resume.hcName')}}</td>
							<td>{{$t('common.resume.getTime')}}</td>
							<td>{{$t('common.resume.unit')}}</td>
							<td>{{$t('common.resume.attaCert')}}</td>
							<td>{{$t('common.resume.desc')}}</td>
							<td></td>
						</tr>
						<tr v-for="(obj, idx) in qualificationList" :key="idx">
							<td><el-input v-model="obj.name" :placeholder="$t('common.resume.inputCertName')" maxlength="20"></el-input></td>
							<td><el-date-picker :editable="false" value-format="yyyy-MM" v-model="obj.getTime" type="month" :placeholder="$t('common.resume.getCertTime')"></el-date-picker></td>
							<td><el-input v-model="obj.issuedUnit" :placeholder="$t('common.resume.inputUnit')" maxlength="20"></el-input></td>
							<td>
								<template v-if="obj.attachment && obj.attachment.path && obj.attachment.path.length">
									<span class="honor-imgs"><img :src="imgUrl + obj.attachment.path" alt="" /></span>
									<p @click="certImgTap(idx)" class="newUp">
										<el-upload
											class="honor-upload flexCenter"
											action=""
											:show-file-list="false"
											:before-upload="certUpload"
										>
											<i class="el-icon-plus"></i>
										</el-upload>
									</p>
								</template>
								<span v-else @click="certImgTap(idx)">
									<el-upload
										class="honor-upload flexCenter"
										action=""
										:show-file-list="false"
										:before-upload="certUpload"
									>
										<i class="el-icon-plus"></i>
									</el-upload>
								</span>
							</td>
							<td><el-input v-model="obj.description" type="textarea" :rows="3" :placeholder="$t('common.resume.inputDesc')" resize="none" maxlength="500"></el-input></td>
							<td>
								<span class="delete" @click="honorDelete(idx)"><i class="el-icon-delete"></i></span>
							</td>
						</tr>
					</table>
				</div>
			</div>

			<!-- 工作经验 -->
			<div class="p-edit-box">
				<div class="p-edit-head flexBetween">
					<div class="zmlTitle">{{$t('common.detail.workExperience')}}</div>
					<span class="zmlAdd color1" @click="addWork">
						<i class="el-icon-circle-plus-outline"></i>
						{{$t('common.detail.add')}}
					</span>
				</div>
				<div v-for="(obj, idx) in workExperiences" :key="idx" class="p-edit-zml p-edit-work">
					<div class="p-edit-row flexBetween">
						<div class="p-edit-cos">
							<label class="p-edit-title">{{$t('common.resume.time')}}：</label>
							<el-date-picker :editable="false" @input="rangeDateInput(idx, 'work')" value-format="yyyy-MM" v-model="obj.date" type="monthrange" range-separator="~" :start-placeholder="$t('common.resume.start')" :end-placeholder="$t('common.resume.end')"></el-date-picker>
						</div>
						<div class="p-edit-cos">
							<label class="p-edit-title">{{$t('common.resume.company')}}：</label>
							<el-input v-model="obj.company" placeholder="" maxlength="20"></el-input>
						</div>
						<div class="p-edit-cos">
							<label class="p-edit-title">{{$t('common.resume.job')}}：</label>
							<el-input v-model="obj.job" placeholder="" maxlength="20"></el-input>
						</div>
					</div>
					<div class="p-edit-row flexBetween">
						<div class="p-edit-cos">
							<label class="p-edit-title">{{$t('common.resume.companyType')}}：</label>
							<el-select v-model="obj.corporateType" :placeholder="$t('common.newJob.select')" :popper-append-to-body="false">
								<el-option v-for="item in work_nature_options" :key="item.value" :label="item.text" :value="item.value"></el-option>
							</el-select>
						</div>
						<div class="p-edit-cos companyXZ">
							<label class="p-edit-title">{{$t('common.resume.industry')}}：</label>
							<el-select v-model="obj.industry" :placeholder="$t('common.newJob.select')" :popper-append-to-body="false">
								<el-option v-for="item in work_industry_options" :key="item.value" :label="item.text" :value="item.value"></el-option>
							</el-select>
						</div>
					</div>
					<div class="p-edit-row">
						<div class="p-edit-cos flex">
							<label class="p-edit-title">{{$t('common.resume.workDesc1')}}：</label>
							<el-input type="textarea" maxlength="500" :rows="5" placeholder="" v-model="obj.description" resize="none"></el-input>
						</div>
					</div>
					<div class="p-edit-row-btns">
						<!-- <button class="zmlBtn2">保存</button> -->
						<span class="h66" @click="workDelete(idx)">{{$t('common.operate.delete')}}</span>
					</div>
				</div>
			</div>

			<!-- 项目经验 -->
			<div class="p-edit-box">
				<div class="p-edit-head flexBetween">
					<div class="zmlTitle">{{$t('common.detail.projectExperience')}}</div>
					<span class="zmlAdd color1" @click="addProject">
						<i class="el-icon-circle-plus-outline"></i>
						{{$t('common.detail.add')}}
					</span>
				</div>
				<div v-for="(obj, idx) in projectExps" :key="idx" class="p-edit-zml p-edit-project">
					<div class="p-edit-row flexBetween">
						<div class="p-edit-cos">
							<label class="p-edit-title">{{$t('common.resume.time')}}：</label>
							<el-date-picker :editable="false" @input="rangeDateInput(idx, 'pro')" value-format="yyyy-MM" v-model="obj.date" type="monthrange" range-separator="~" :start-placeholder="$t('common.resume.start')" :end-placeholder="$t('common.resume.end')"></el-date-picker>
						</div>
						<div class="p-edit-cos companyXZ">
							<label class="p-edit-title">{{$t('common.resume.belongCom')}}：</label>
							<el-input v-model="obj.company" placeholder="" maxlength="20"></el-input>
						</div>
					</div>
					<div class="p-edit-row flexBetween">
						<div class="p-edit-cos">
							<label class="p-edit-title">{{$t('common.resume.project')}}：</label>
							<el-input v-model="obj.projectName" placeholder="" maxlength="20"></el-input>
						</div>
						<div class="p-edit-cos companyXZ">
							<label class="p-edit-title">{{$t('common.resume.proDuty')}}：</label>
							<el-input v-model="obj.duties" placeholder="" maxlength="100"></el-input></el-input>
						</div>
					</div>
					<div class="p-edit-row">
						<div class="p-edit-cos flex">
							<label class="p-edit-title">{{$t('common.resume.workDesc')}}：</label>
							<el-input type="textarea" :rows="5" placeholder="" v-model="obj.description" resize="none" maxlength="500"></el-input>
						</div>
					</div>
					<div class="p-edit-row-btns">
						<!-- <button class="zmlBtn2">保存</button> -->
						<span class="h66" @click="projectDelete(idx)">{{$t('common.operate.delete')}}</span>
					</div>
				</div>
			</div>

			<!-- 简历附件 -->
			<div class="p-edit-box fujian">
				<div class="zmlTitle">{{$t('common.detail.attachmentResume')}}</div>
				<div class="company-userinfo-head flex">
					<div class="company-userinfo-head-img flexCenter">
						<!-- <img :src="fjImg" alt="" v-if="fjImg != ''" />
						<span v-else>{{$t('common.detail.enclosure')}}</span> -->
						<span v-if="attachment">{{attachment.name}}</span>
						<span v-else>{{$t('common.detail.enclosure')}}</span>
					</div>
					<div class="company-userinfo-head-text flexColumn">
						<p class="h99">{{$t('common.resume.support')}}</p>
						<p class="h99">{{$t('common.resume.fileSize')}}</p>
						<el-upload action=""  :before-upload="fjUpload" :on-progress='uploadedJD'>
							<span class="color1">{{ $t('common.company.upload') }}</span>
						</el-upload>
						<el-progress :percentage="progressPercent" v-if="progressFlag"></el-progress>
					</div>
				</div>
				<div class="tips h99 font12" style="margin-top:10px">{{$t('common.tips.jlTip')}}</div>
			</div>
			
			<div class="recruit-edit-btn flexCenter" style="padding-top: 30px; padding-bottom: 30px;">
				<button class="zmlBtn1" @click="saveTap()">{{$t('common.newJob.save')}}</button>
				<button class="zmlBtn3" style="margin-left: 30px;" @click="$router.back()">{{$t('common.company.cancel')}}</button>
			</div>
		</div>
	</div>
</template>
<script>
import {ajax,ajaxAdd,showToast,beforeUpload,ajaxBackAdd} from '@/utils/js.js'
import {uploadFile,styleList,getProvinceCityJson,perfectResume,resumeDetail,getNationAndHujiJson} from '../../services/api.js'
const log = console.log
import info from '@/components/userInfo.vue'
export default {
	components:{
		'v-info':info
	},
	data() {
		return {
			submitShow:true,
			a1:[ "210000", "210002" ],
			imgUrl: this.$store.state.imgUrl,
			userInfo:this.$store.state.userInfo,
			attachment:{},
			resource: {
				"id": "",
				"userId": this.$store.state.userInfo.id,
				"headPicture": "",
				"userName": "",
				"sex": "",
				"telentType": '', //人才类别:0校园人才，1社会人才
				"topEducation": "",
				"birthDate": "",
				"topUniversity": "",
				"domicileNationality": "", //户籍
				"idNumber": "", //身份证
				"married": "",
				"phone": "",
				"email": "",
				"address": "", //居住地
				"major": "", //专业
				"graduateTime": "", //毕业时间
				"industry": "", //行业
				"salaryRange": '',
				"identityProperties": '',//身份性质
				"resumeFile":'', //简历附件id
				"attachmentList": [{ //附件列表
					"createTime": "",
					"createUser": "",
					"id": "",
					"name": "附件",
					"path": "",
					"type": "",
				}],
			},
			eduInfos: [{
				"date": '',
				"startDate": "",
				"endDate": "",
				"schoolName": "",
				"education": "",
				"educationTxt": "",
				"professional": "",
				"description": "",
				"userId": this.$store.state.userInfo.id,
				"id": "",
			}],
			
			qualificationList: [{
				"id": "",
				"userId": this.$store.state.userInfo.id,
				"name": "", //证书名称
				"getTime": "", //获取时间
				"issuedUnit": "", //颁发单位
				"attachmentId": "",
				"description": "",
				"attachment": {
					"createTime": "",
					"createUser": "",
					"id": "",
					"name": "",
					"path": "",
					"type": "",
				}
			}],
			
			workExperiences: [{
				"date": "",
				"startDate": "",
				"endDate": "",
				"company": "",
				"corporateType": "", //公司性质
				"description": "", //工作描述
				"id": "",
				"industry": "", //行业
				"job": "",
				"userId": this.$store.state.userInfo.id
			}],
			
			projectExps: [{
				"date": "",
				"startDate": "",
				"endDate": "",
				"company": "",
				"description": "",
				"duties": "", //项目职责
				"id": "",
				"projectName": "",
				"userId": this.$store.state.userInfo.id
			}],
			
			options_price: [], //薪资列表
			options_sex: [], //性别列表
			options_nature: [], //身份性质列表
			options_marry: [], //婚姻
			
			address: '',
			options_address: [], //现居地列表
			domicileNationality: '',
			options_house: [], //户籍列表
			
			education_educa_options: [], //教育信息---学历列表

			work_nature_options: [], //工作经验 ---公司性质列表
			work_industry_options: [], //工作经验 ---行业列表
			
			certIdx: 0, //证书上传图片下标

			progressFlag:false,
			progressPercent:0
		};
	},
	mounted() {
		this.content();
	},
	watch: {
		"$i18n.locale"() {
			this.content();
		},
	},
	methods: {
		getPhone(e){
			console.log(e)
			if(e.substr(0,1) !=1){
				this.resource.phone = ''
			}else{
				this.resource.phone = parseInt(e) || ''
			}
		},
		getidNumber(e){
			console.log(e)
			let cn = /[\u4E00-\u9FA5]/g
			this.resource.idNumber = e.replace(cn,'')
		},
		rangeDateInput(idx, type) {
			if (type == 'edu') {
				var obj = this.eduInfos[idx]
				this.$set(this.eduInfos, idx, obj)
			}
			if (type == 'work') {
				var obj = this.workExperiences[idx]
				this.$set(this.workExperiences, idx, obj)
			}
			if (type == 'pro') {
				var obj = this.projectExps[idx]
				this.$set(this.projectExps, idx, obj)
			}
		},
		content() {
			//简历详情
			ajaxAdd(this, resumeDetail, {}, res => {
				console.log('简历详情',res.data)
				//基本信息
				if (res.data.resource && Object.getOwnPropertyNames(res.data.resource).length > 0) {
					this.resource = res.data.resource;
					if(res.data.resource.domicileNationality){
						let domicileNationality =res.data.resource.domicileNationality
						domicileNationality = domicileNationality.substr(1,domicileNationality.length-2)
						this.domicileNationality = domicileNationality.split(',')
					}
					if(res.data.resource.address){
						let domicileNationality =res.data.resource.address
						domicileNationality = domicileNationality.substr(1,domicileNationality.length-2)
						this.address = domicileNationality.split(',')
					}
				}
				//教育
				if (res.data.eduInfos && res.data.eduInfos.length > 0) {
					this.eduInfos = res.data.eduInfos
					for (var i=0; i<this.eduInfos.length; i++) {
						var obj = this.eduInfos[i]
						if (obj.startDate != null && obj.endDate != null) {
							obj.date = [obj.startDate, obj.endDate]
						} else {
							obj.date = ''
						}
					}
				}
				//证书
				if (res.data.qualificationList && res.data.qualificationList.length > 0) {
					this.qualificationList = res.data.qualificationList
				}
				//工作经验
				if (res.data.workExperiences && res.data.workExperiences.length > 0) {
					this.workExperiences = res.data.workExperiences
					for (var i=0; i<this.workExperiences.length; i++) {
						var obj = this.workExperiences[i]
						if (obj.startDate != null && obj.endDate != null) {
							obj.date = [obj.startDate, obj.endDate]
						} else {
							obj.date = ''
						}
					}
				}
				//项目经验
				if (res.data.projectExps && res.data.projectExps.length > 0) {
					this.projectExps = res.data.projectExps
					for (var i=0; i<this.projectExps.length; i++) {
						var obj = this.projectExps[i]
						if (obj.startDate != null && obj.endDate != null) {
							obj.date = [obj.startDate, obj.endDate]
						} else {
							obj.date = ''
						}
					}
				}
				res.data.attachment ? this.attachment = res.data.attachment : this.attachment = {}
			})
			
			// 薪资范围
			ajax(this, styleList, { lxjp: 'salaryRange' }, res => {
				this.options_price = res.data;
			})
			
			//性别
			ajax(this, styleList, { lxjp: 'sex' }, res => {
				this.options_sex = res.data;
			})
			
			//身份性质
			ajax(this, styleList, { lxjp: 'IDENTITY_PROPERTIES' }, res => {
				this.options_nature = res.data;
			})
			
			// 省市
			ajaxBackAdd(this, getProvinceCityJson, {}, res => {
				this.options_address = JSON.parse(res.data);
			});
			// 户籍
			ajaxBackAdd(this, getNationAndHujiJson, {}, res => {
				this.options_house = JSON.parse(res.data);
			});
			
			//婚姻
			ajax(this, styleList, { lxjp: 'married' }, res => {
				this.options_marry = res.data;
			})
			
			//学历
			ajax(this, styleList, { lxjp: "education" }, (res) => {
				this.education_educa_options = res.data;
			});
			
			//公司性质
			ajax(this, styleList, { lxjp: "corporateType" }, (res) => {
				this.work_nature_options = res.data;
			});
			
			//行业
			ajax(this, styleList, { lxjp: "industry" }, (res) => {
				this.work_industry_options = res.data;
			});

		},
		//校验数据是否必填
		canSubmit() {
			this.postData()
			if (this.resource.salaryRange == null || this.resource.salaryRange == '') {
				showToast(this, this.$t('common.resume.selectSalary'));
				return false
			}
			if (this.resource.userName == null || this.resource.userName == '') {
				showToast(this, this.$t('common.resume.inputName'));
				return false
			}
			if (this.resource.sex == null || this.resource.sex == '') {
				showToast(this, this.$t('common.resume.selectSex'));
				return false
			}
			if (this.resource.identityProperties == null || this.resource.identityProperties == '') {
				showToast(this, this.$t('common.resume.selectNature'));
				return false
			}
			if (this.domicileNationality == '') {
				showToast(this, this.$t('common.resume.selectHuji'));
				return false
			}
			// if (this.resource.idNumber == null || this.resource.idNumber == '') {
			// 	showToast(this, this.$t('common.resume.inputIdcard'));
			// 	return false
			// }
			if (this.resource.married == null || this.resource.married == '') {
				showToast(this, this.$t('common.resume.selectMarry'));
				return false
			}
			if (this.resource.phone == null || this.resource.phone == '') {
				showToast(this, this.$t('common.resume.inputPhone'));
				return false
			}
			// let email = /^(\w+)(\.\w+)*@\w+(\.\w+)*$/
			let email = /^[A-Za-z\d]+([-_.][A-Za-z\d]+)*@([A-Za-z\d]+[-.])+[A-Za-z\d]{2,4}$/
			if (this.resource.email == null || this.resource.email == '') {
				showToast(this, this.$t('common.resume.inputMail'));
				return false
			}
			if (!email.test(this.resource.email)) {
				showToast(this, this.$t('common.resume.inputMailerr'));
				return false
			}
			if (this.address == '') {
				showToast(this, this.$t('common.resume.selectAddress'));
				return false
			}
			let eduInfos = this.eduInfos
			for(let i = 0; i < eduInfos.length; i++){
				let curData = eduInfos[i]
				if(curData.date.length == 0) return showToast(this,'请选择教育时间！')
				if(curData.schoolName.length == 0) return showToast(this,'请输入学校！')
				if(curData.education.length == 0) return showToast(this,'请选择学历！')
				if(curData.professional.length == 0) return showToast(this,'请输入专业！')
			}
			// 荣誉证书
			let qualificationList = this.qualificationList  
			for(let i = 0; i < qualificationList.length; i++){
				let curData = qualificationList[i]
				if(curData.name.length == 0) return showToast(this,'请输入证书名称！')
				if(curData.getTime.length == 0) return showToast(this,'请选择获取证书时间！')
				if(curData.issuedUnit.length == 0) return showToast(this,'请输入颁证单位！')
			}
			// 工作经验
			let workExperiences = this.workExperiences  
			for(let i = 0; i < workExperiences.length; i++){
				let curData = workExperiences[i]
				if(curData.date.length == 0) return showToast(this,'请选择工作经验时间！')
				if(curData.company.length == 0) return showToast(this,'请输入公司名称！')
				if(curData.job.length == 0) return showToast(this,'请输入职位！')
				if(curData.corporateType.length == 0) return showToast(this,'请选择公司性质！')
				if(curData.industry.length == 0) return showToast(this,'请选择行业！')
				if(curData.description.length == 0) return showToast(this,'请输入工作描述！')
			}
			// 项目经验
			let projectExps = this.projectExps  
			for(let i = 0; i < projectExps.length; i++){
				let curData = projectExps[i]
				console.log(curData)
				if(curData.date.length == 0) return showToast(this,'请选择项目经验时间！')
				if(curData.company.length == 0) return showToast(this,'请输入公司名称！')
				if(curData.projectName.length == 0) return showToast(this,'请输入项目名称！')
				if(curData.duties.length == 0) return showToast(this,'请输入项目职责！')
				if(curData.description.length == 0) return showToast(this,'请输入项目描述！')
			}
			console.log('666')
			return true
		},
		
		postData() {
			this.resource.address = "["+this.address[0].toString() + "," + this.address[1].toString() + "," + this.address[2].toString()+"]"
			this.resource.domicileNationality = "["+this.domicileNationality[0].toString() + "," + this.domicileNationality[1].toString()+"]"
			if(this.domicileNationality.length == 3){
				this.resource.domicileNationality = "["+this.domicileNationality[0].toString() + "," + this.domicileNationality[1].toString() + "," + this.domicileNationality[2].toString()+"]"
			}
			
			for (var i=0; i<this.eduInfos.length; i++) {
				var obj = this.eduInfos[i]
				console.log(obj)
				if (obj.date != '') {
					obj.startDate = obj.date[0]
					obj.endDate = obj.date[1]
				}
			}
			for (var i=0; i<this.workExperiences.length; i++) {
				var obj = this.workExperiences[i]
				if (obj.date != '') {
					obj.startDate = obj.date[0]
					obj.endDate = obj.date[1]
				}
			}
			for (var i=0; i<this.projectExps.length; i++) {
				var obj = this.projectExps[i]
				if (obj.date != '') {
					obj.startDate = obj.date[0]
					obj.endDate = obj.date[1]
				}
			}
			let data = {
				eduInfos: this.eduInfos,
				projectExps: this.projectExps,
				qualificationList: this.qualificationList,
				resource: this.resource,
				workExperiences: this.workExperiences,
				attachment:this.attachment
			}
			
			log(data)
			return data
		},
		
		saveTap() {
			if (this.canSubmit()) {
				this.saveReq()
			}
		},
		
		saveReq() {
			let data = this.postData()
			if(this.submitShow){
				this.submitShow = false
				ajaxAdd(this, perfectResume, data, res => {
					this.$message({ message: res.msg, type: 'success' });
					this.$router.back()
					setTimeout(()=>{
						this.submitShow = true
					},5000)
				},err=>{
					this.submitShow = true
				})
			}
			
		},
		
		certImgTap(idx) {
			this.certIdx = idx
		},
		
		// 选择户籍
		handleChangeHouse(value) {
			console.log(value);
		},
		// 选择现居地
		handleChangeAddress(value) {
			console.log(value);
		},

		// 教育信息----添加
		addEducation() {
			this.eduInfos.push({
				"date": '',
				"startDate": "",
				"endDate": "",
				"schoolName": "",
				"education": "",
				"educationTxt": "",
				"professional": "",
				"description": "",
				"userId": this.$store.state.userInfo.id,
				"id": "",
			})
			// this.$message({ message: '添加教育信息', type: 'success' });
		},
		// 荣誉与证书----添加
		addHonor() {
			this.qualificationList.push({
				"id": "",
				"userId": this.$store.state.userInfo.id,
				"name": "", //证书名称
				"getTime": "", //获取时间
				"issuedUnit": "", //颁发单位
				"attachmentId": "",
				"description": "",
				"attachment": {
					"createTime": "",
					"createUser": "",
					"id": "",
					"name": "",
					"path": "",
					"type": "",
				}
			})
		},
		// 工作经验----添加
		addWork() {
			this.workExperiences.push({
				"date": "",
				"startDate": "",
				"endDate": "",
				"company": "",
				"corporateType": "", //公司性质
				"description": "", //工作描述
				"id": "",
				"industry": "", //行业
				"job": "",
				"userId": this.$store.state.userInfo.id
			})
		},
		// 项目经验----添加
		addProject() {
			this.projectExps.push({
				"date": "",
				"startDate": "",
				"endDate": "",
				"company": "",
				"description": "",
				"duties": "", //项目职责
				"id": "",
				"projectName": "",
				"userId": this.$store.state.userInfo.id
			})
		},
		
		// 教育信息----删除
		educaDelete(idx) {
			this.eduInfos.splice(idx, 1)
			// this.$message({ message: '删除教育信息', type: 'success' });
		},
		// 荣誉及证书----删除
		honorDelete(idx) {
			this.qualificationList.splice(idx, 1)
			// this.$message({ message: '删除荣誉及证书', type: 'success' });
		},
		// 工作经验----删除
		workDelete(idx) {
			this.workExperiences.splice(idx, 1)
			// this.$message({ message: '删除荣誉及证书', type: 'success' });
		},
		// 项目经验----删除
		projectDelete(idx) {
			this.projectExps.splice(idx, 1)
			// this.$message({ message: '删除荣誉及证书', type: 'success' });
		},

		//头像上传
		photoUpload(file) {
			let data = new FormData();
			data.append('file', file);
			console.log('photoUpload==',file)
			const typeList = ["jpg", "png"];
			beforeUpload(file,typeList,3072000,d=>{
				ajax(this, uploadFile, data, res => {
					let getData = res.data
					getData.belongType = 3
					this.resource.attachmentList[0]=getData
					this.resource.headPicture = res.data.path
				});
			})
			
		},
		
		// 荣誉证书---附件证书
		certUpload(file) {
			let data = new FormData();
			data.append('file', file);
			console.log('photoUpload==',file)
			const typeList = ["jpg", "png"];
			beforeUpload(file,typeList,3072000,d=>{
				ajax(this, uploadFile, data, res => {
					var obj = this.qualificationList[this.certIdx]
				obj.attachmentId = res.data.id
				obj.attachment = res.data
				});
			})
			// ajax(this, uploadFile, data, res => {
			// 	var obj = this.qualificationList[this.certIdx]
			// 	obj.attachmentId = res.data.id
			// 	obj.attachment = res.data
			// });
		},
		uploadedJD(event, file, fileList){
			
		},
		// 附件
		fjUpload(file) {
			let data = new FormData();
			data.append('file', file);
			console.log(file)
			const typeList = ["doc", "docx","pdf"];
			beforeUpload(file,typeList,500000,d=>{
				ajax(this, uploadFile, data, res => {
					this.attachment = res.data
					showToast(this,res.msg,1)
				});
			})
			
		},
	}
};
</script>
<style lang="scss">
.p-resume-edit {
	.p-resume-edit-btn {
		height: 72px;
		justify-content: flex-end;
		button {
			margin-left: 15px;
		}
	}
	.p-edit-content {
		width: 100%;
		height: auto;
		background-color: #fff;
		padding: 0 30px;
		.company-userinfo-head {
			padding: 30px 0;
			border-bottom: 1px solid #d1d1d1;
			.company-userinfo-head-img {
				width: 100px;
				height: 134px;
				overflow: hidden;
				background-color: #f5f5f5;
				color: #999;
			}
			.company-userinfo-head-text {
				flex: 1;
				padding: 20px 0;
				padding-left: 20px;
				justify-content: space-between;
			}
		}
		.p-edit-box {
			padding-bottom: 30px;
			border-bottom: 1px solid #d6d7dc;
		}
		.p-edit-box:nth-last-of-type(1) {
			border-bottom: 0;
		}
		.fujian {
			.company-userinfo-head {
				border-bottom: 0;
				padding: 0;
			}
		}

		.p-edit-infor,
		.p-edit-education,
		.p-edit-work,
		.p-edit-project {
			padding-right: 30px;
			.el-input__inner {
				height: 36px;
				line-height: 36px;
				width: 200px;
			}
		}
		.p-edit-zml {
			padding-bottom: 20px;
		}
		.p-edit-zml:nth-last-of-type(1) {
			padding-bottom: 0;
		}
		.p-edit-honor {
			table {
				width: 100%;
			}
			tr:nth-of-type(1) {
				background-color: #f2f6fe;
				text-align: center;
				height: 40px;
				td {
					padding: 0;
				}
				td:nth-of-type(1) {
					text-align: left;
					padding-left: 26px;
				}
			}
			tr {
				border: 1px solid #ededed;
				td {
					padding: 20px 0 20px 12px;
					.delete {
						padding-right: 12px;
						cursor: pointer;
					}
					.newUp .honor-upload{height:30px;}
					.honor-imgs {
						display: inline-block;
						width: 60px;
						height: 76px;
						overflow: hidden;
						img {
							width: 100%;
							height: 100%;
							object-fit: contain;
						}
					}
				}
			}
			.honor-upload {
				width: 60px;
				height: 76px;
				background-color: #f5f5f5;
				.el-upload {
					width: 100%;
					height: 100%;
					display: flex;
					align-items: center;
					justify-content: center;
				}
			}
		}
	}
	.zmlAdd {
		cursor: pointer;
		user-select: none;
		i {
			margin-right: 5px;
		}
	}
	.p-edit-row {
		padding: 6px 0;
		.companyXZ {
			flex: 1;
			display: flex;
			.p-edit-title {
				padding-left: 18px;
			}
			.el-input {
				width: 100%;
				input {
					width: 100%;
				}
			}
			.el-cascader {
				flex: 1;
				.el-input {
					width: 100%;
				}
				input {
					width: 100%;
				}
			}
		}
	}
	.p-edit-row-btns {
		padding-top: 20px;
		padding-left: 85px;
		button {
			margin-right: 46px;
		}
		span {
			cursor: pointer;
		}
	}
	.p-edit-title {
		display: inline-block;
		width: 85px;
		text-align: right;
		line-height: 36px;
		color: #666;
	}
	.el-input {
		width: auto;
	}
	.el-textarea {
		flex: 1;
	}
	.userInfo-head{margin-bottom:20px;}
	.userInfo-head-speed .wanshanInfo{display: none;}
}
</style>
